{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [],
   "source": [
    "import numpy as np\n",
    "import regTrees\n",
    "import utils"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 划分"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "mat0 =  [[0. 1. 0. 0.]]\n",
      "mat1 =  [[1. 0. 0. 0.]\n",
      " [0. 0. 1. 0.]\n",
      " [0. 0. 0. 1.]]\n"
     ]
    }
   ],
   "source": [
    "testMat=np.eye(4)\n",
    "mat0,mat1=regTrees.binSplitDataSet(testMat,1,0.5)\n",
    "print (\"mat0 = \", mat0)\n",
    "print (\"mat1 = \", mat1)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Expect Result:  \n",
    "\n",
    "mat0 =  [[0. 1. 0. 0.]]  \n",
    "mat1 =  [[1. 0. 0. 0.]  \n",
    " [0. 0. 1. 0.]  \n",
    " [0. 0. 0. 1.]]"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 建树"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'feature': 0,\n",
       " 'value': 0.48813,\n",
       " 'left': 1.0180967672413792,\n",
       " 'right': -0.04465028571428572}"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "myDat=utils.loadDataSet('ex00.txt')\n",
    "regTrees.createTree(myDat)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'feature': 1,\n",
       " 'value': 0.39435,\n",
       " 'left': {'feature': 1,\n",
       "  'value': 0.582002,\n",
       "  'left': {'feature': 1,\n",
       "   'value': 0.797583,\n",
       "   'left': 3.9871632,\n",
       "   'right': 2.9836209534883724},\n",
       "  'right': 1.980035071428571},\n",
       " 'right': {'feature': 1,\n",
       "  'value': 0.197834,\n",
       "  'left': 1.0289583666666666,\n",
       "  'right': -0.023838155555555553}}"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "myDat1=utils.loadDataSet('ex0.txt')\n",
    "regTrees.createTree(np.array(myDat1))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'feature': 0,\n",
       " 'value': 0.48813,\n",
       " 'left': {'feature': 0,\n",
       "  'value': 0.620599,\n",
       "  'left': {'feature': 0,\n",
       "   'value': 0.625336,\n",
       "   'left': {'feature': 0,\n",
       "    'value': 0.625791,\n",
       "    'left': {'feature': 0,\n",
       "     'value': 0.643601,\n",
       "     'left': {'feature': 0,\n",
       "      'value': 0.651376,\n",
       "      'left': {'feature': 0,\n",
       "       'value': 0.6632,\n",
       "       'left': {'feature': 0,\n",
       "        'value': 0.683921,\n",
       "        'left': {'feature': 0,\n",
       "         'value': 0.819823,\n",
       "         'left': {'feature': 0,\n",
       "          'value': 0.837522,\n",
       "          'left': {'feature': 0,\n",
       "           'value': 0.846455,\n",
       "           'left': {'feature': 0,\n",
       "            'value': 0.919384,\n",
       "            'left': {'feature': 0,\n",
       "             'value': 0.976414,\n",
       "             'left': {'feature': 0,\n",
       "              'value': 0.985425,\n",
       "              'left': {'feature': 0,\n",
       "               'value': 0.989888,\n",
       "               'left': {'feature': 0,\n",
       "                'value': 0.993349,\n",
       "                'left': 1.035533,\n",
       "                'right': 1.077553},\n",
       "               'right': {'feature': 0,\n",
       "                'value': 0.988852,\n",
       "                'left': 0.744207,\n",
       "                'right': 1.069062}},\n",
       "              'right': 1.227946},\n",
       "             'right': {'feature': 0,\n",
       "              'value': 0.953112,\n",
       "              'left': {'feature': 0,\n",
       "               'value': 0.975022,\n",
       "               'left': 0.862911,\n",
       "               'right': 0.673579},\n",
       "              'right': {'feature': 0,\n",
       "               'value': 0.948268,\n",
       "               'left': {'feature': 0,\n",
       "                'value': 0.951949,\n",
       "                'left': 1.06469,\n",
       "                'right': {'feature': 0,\n",
       "                 'value': 0.950153,\n",
       "                 'left': 0.945255,\n",
       "                 'right': 1.022906}},\n",
       "               'right': {'feature': 0,\n",
       "                'value': 0.936783,\n",
       "                'left': 0.631862,\n",
       "                'right': {'feature': 0,\n",
       "                 'value': 0.928097,\n",
       "                 'left': {'feature': 0,\n",
       "                  'value': 0.930173,\n",
       "                  'left': 1.026258,\n",
       "                  'right': 1.035645},\n",
       "                 'right': 0.883225}}}}},\n",
       "            'right': {'feature': 0,\n",
       "             'value': 0.877241,\n",
       "             'left': {'feature': 0,\n",
       "              'value': 0.897094,\n",
       "              'left': {'feature': 0,\n",
       "               'value': 0.902532,\n",
       "               'left': {'feature': 0,\n",
       "                'value': 0.919074,\n",
       "                'left': 1.029889,\n",
       "                'right': 1.123413},\n",
       "               'right': {'feature': 0,\n",
       "                'value': 0.901056,\n",
       "                'left': 0.861601,\n",
       "                'right': {'feature': 0,\n",
       "                 'value': 0.900272,\n",
       "                 'left': 1.0559,\n",
       "                 'right': 0.996871}}},\n",
       "              'right': {'feature': 0,\n",
       "               'value': 0.89593,\n",
       "               'left': 1.240209,\n",
       "               'right': {'feature': 0,\n",
       "                'value': 0.884512,\n",
       "                'left': 1.077275,\n",
       "                'right': 1.117833}}},\n",
       "             'right': {'feature': 0,\n",
       "              'value': 0.848921,\n",
       "              'left': {'feature': 0,\n",
       "               'value': 0.860049,\n",
       "               'left': {'feature': 0,\n",
       "                'value': 0.869077,\n",
       "                'left': 0.797005,\n",
       "                'right': 1.114825},\n",
       "               'right': 0.71749},\n",
       "              'right': 1.170959}}},\n",
       "           'right': {'feature': 0,\n",
       "            'value': 0.845815,\n",
       "            'left': 0.72003,\n",
       "            'right': 0.952617}},\n",
       "          'right': {'feature': 0,\n",
       "           'value': 0.821648,\n",
       "           'left': {'feature': 0,\n",
       "            'value': 0.834078,\n",
       "            'left': 1.229373,\n",
       "            'right': {'feature': 0,\n",
       "             'value': 0.824442,\n",
       "             'left': 1.01058,\n",
       "             'right': {'feature': 0,\n",
       "              'value': 0.822443,\n",
       "              'left': 1.082153,\n",
       "              'right': 1.086648}}},\n",
       "           'right': {'feature': 0,\n",
       "            'value': 0.820802,\n",
       "            'left': 1.280895,\n",
       "            'right': 1.325907}}},\n",
       "         'right': {'feature': 0,\n",
       "          'value': 0.785541,\n",
       "          'left': {'feature': 0,\n",
       "           'value': 0.79024,\n",
       "           'left': {'feature': 0,\n",
       "            'value': 0.813719,\n",
       "            'left': {'feature': 0,\n",
       "             'value': 0.814825,\n",
       "             'left': 0.835264,\n",
       "             'right': 1.095206},\n",
       "            'right': {'feature': 0,\n",
       "             'value': 0.804586,\n",
       "             'left': 0.706601,\n",
       "             'right': {'feature': 0,\n",
       "              'value': 0.795072,\n",
       "              'left': 0.924033,\n",
       "              'right': 0.965721}}},\n",
       "           'right': {'feature': 0,\n",
       "            'value': 0.789625,\n",
       "            'left': 0.533214,\n",
       "            'right': 0.552614}},\n",
       "          'right': {'feature': 0,\n",
       "           'value': 0.712503,\n",
       "           'left': {'feature': 0,\n",
       "            'value': 0.72312,\n",
       "            'left': {'feature': 0,\n",
       "             'value': 0.768784,\n",
       "             'left': {'feature': 0,\n",
       "              'value': 0.773422,\n",
       "              'left': {'feature': 0,\n",
       "               'value': 0.782167,\n",
       "               'left': 1.165296,\n",
       "               'right': {'feature': 0,\n",
       "                'value': 0.774301,\n",
       "                'left': {'feature': 0,\n",
       "                 'value': 0.78193,\n",
       "                 'left': 0.886049,\n",
       "                 'right': 1.074488},\n",
       "                'right': 0.836763}},\n",
       "              'right': {'feature': 0,\n",
       "               'value': 0.772083,\n",
       "               'left': {'feature': 0,\n",
       "                'value': 0.773168,\n",
       "                'left': 1.125943,\n",
       "                'right': 1.140917},\n",
       "               'right': 1.299018}},\n",
       "             'right': {'feature': 0,\n",
       "              'value': 0.742527,\n",
       "              'left': {'feature': 0,\n",
       "               'value': 0.750918,\n",
       "               'left': {'feature': 0,\n",
       "                'value': 0.761474,\n",
       "                'left': {'feature': 0,\n",
       "                 'value': 0.768596,\n",
       "                 'left': 0.899705,\n",
       "                 'right': 0.760219},\n",
       "                'right': 1.058262},\n",
       "               'right': {'feature': 0,\n",
       "                'value': 0.750078,\n",
       "                'left': 0.748104,\n",
       "                'right': 0.906291}},\n",
       "              'right': {'feature': 0,\n",
       "               'value': 0.729234,\n",
       "               'left': {'feature': 0,\n",
       "                'value': 0.737189,\n",
       "                'left': 1.087056,\n",
       "                'right': 1.200781},\n",
       "               'right': {'feature': 0,\n",
       "                'value': 0.727098,\n",
       "                'left': 0.931956,\n",
       "                'right': {'feature': 0,\n",
       "                 'value': 0.726828,\n",
       "                 'left': 1.000567,\n",
       "                 'right': 1.017112}}}}},\n",
       "            'right': 1.307248},\n",
       "           'right': {'feature': 0,\n",
       "            'value': 0.703755,\n",
       "            'left': {'feature': 0,\n",
       "             'value': 0.712386,\n",
       "             'left': 0.93349,\n",
       "             'right': 0.564858},\n",
       "            'right': {'feature': 0,\n",
       "             'value': 0.696648,\n",
       "             'left': {'feature': 0,\n",
       "              'value': 0.697718,\n",
       "              'left': {'feature': 0,\n",
       "               'value': 0.697777,\n",
       "               'left': 1.101678,\n",
       "               'right': 0.827805},\n",
       "              'right': 1.212434},\n",
       "             'right': {'feature': 0,\n",
       "              'value': 0.691115,\n",
       "              'left': 0.845423,\n",
       "              'right': 0.834391}}}}}},\n",
       "        'right': {'feature': 0,\n",
       "         'value': 0.683886,\n",
       "         'left': 1.414382,\n",
       "         'right': {'feature': 0,\n",
       "          'value': 0.678287,\n",
       "          'left': {'feature': 0,\n",
       "           'value': 0.67939,\n",
       "           'left': 0.999985,\n",
       "           'right': 1.307217},\n",
       "          'right': {'feature': 0,\n",
       "           'value': 0.66387,\n",
       "           'left': {'feature': 0,\n",
       "            'value': 0.673195,\n",
       "            'left': 0.907727,\n",
       "            'right': 0.915077},\n",
       "           'right': 1.187129}}}},\n",
       "       'right': {'feature': 0,\n",
       "        'value': 0.656218,\n",
       "        'left': {'feature': 0,\n",
       "         'value': 0.661923,\n",
       "         'left': 0.701634,\n",
       "         'right': 0.76704},\n",
       "        'right': {'feature': 0,\n",
       "         'value': 0.652121,\n",
       "         'left': 0.958506,\n",
       "         'right': 1.004346}}},\n",
       "      'right': {'feature': 0,\n",
       "       'value': 0.645762,\n",
       "       'left': {'feature': 0,\n",
       "        'value': 0.648675,\n",
       "        'left': 1.315384,\n",
       "        'right': 1.287407},\n",
       "       'right': {'feature': 0,\n",
       "        'value': 0.643665,\n",
       "        'left': 1.026886,\n",
       "        'right': 1.024241}}},\n",
       "     'right': {'feature': 0,\n",
       "      'value': 0.626011,\n",
       "      'left': 0.782552,\n",
       "      'right': 0.840544}},\n",
       "    'right': 1.244731},\n",
       "   'right': {'feature': 0,\n",
       "    'value': 0.622398,\n",
       "    'left': 0.623696,\n",
       "    'right': 0.76633}},\n",
       "  'right': {'feature': 0,\n",
       "   'value': 0.61127,\n",
       "   'left': {'feature': 0,\n",
       "    'value': 0.613765,\n",
       "    'left': 1.334421,\n",
       "    'right': 1.621091},\n",
       "   'right': {'feature': 0,\n",
       "    'value': 0.517921,\n",
       "    'left': {'feature': 0,\n",
       "     'value': 0.541314,\n",
       "     'left': {'feature': 0,\n",
       "      'value': 0.559763,\n",
       "      'left': {'feature': 0,\n",
       "       'value': 0.590062,\n",
       "       'left': {'feature': 0,\n",
       "        'value': 0.595012,\n",
       "        'left': {'feature': 0,\n",
       "         'value': 0.597409,\n",
       "         'left': {'feature': 0,\n",
       "          'value': 0.604529,\n",
       "          'left': 0.982036,\n",
       "          'right': 1.212685},\n",
       "         'right': 0.97477},\n",
       "        'right': {'feature': 0,\n",
       "         'value': 0.59021,\n",
       "         'left': 1.213435,\n",
       "         'right': 1.336661}},\n",
       "       'right': {'feature': 0,\n",
       "        'value': 0.589575,\n",
       "        'left': 0.705531,\n",
       "        'right': {'feature': 0,\n",
       "         'value': 0.575805,\n",
       "         'left': {'feature': 0,\n",
       "          'value': 0.576946,\n",
       "          'left': {'feature': 0,\n",
       "           'value': 0.578252,\n",
       "           'left': 1.185812,\n",
       "           'right': 0.921885},\n",
       "          'right': 1.234129},\n",
       "         'right': {'feature': 0,\n",
       "          'value': 0.574573,\n",
       "          'left': 0.89909,\n",
       "          'right': {'feature': 0,\n",
       "           'value': 0.561362,\n",
       "           'left': {'feature': 0,\n",
       "            'value': 0.567704,\n",
       "            'left': 1.06613,\n",
       "            'right': 0.969058},\n",
       "           'right': 1.070529}}}}},\n",
       "      'right': {'feature': 0,\n",
       "       'value': 0.552381,\n",
       "       'left': {'feature': 0,\n",
       "        'value': 0.55299,\n",
       "        'left': {'feature': 0,\n",
       "         'value': 0.55352,\n",
       "         'left': 1.253151,\n",
       "         'right': 1.391273},\n",
       "        'right': 1.036158},\n",
       "       'right': 1.36963}},\n",
       "     'right': {'feature': 0,\n",
       "      'value': 0.520207,\n",
       "      'left': {'feature': 0,\n",
       "       'value': 0.536689,\n",
       "       'left': {'feature': 0,\n",
       "        'value': 0.539558,\n",
       "        'left': 0.893748,\n",
       "        'right': 1.053846},\n",
       "       'right': {'feature': 0,\n",
       "        'value': 0.529491,\n",
       "        'left': {'feature': 0,\n",
       "         'value': 0.530897,\n",
       "         'left': 0.867284,\n",
       "         'right': 0.893462},\n",
       "        'right': {'feature': 0,\n",
       "         'value': 0.527505,\n",
       "         'left': 1.022206,\n",
       "         'right': 0.87956}}},\n",
       "      'right': {'feature': 0,\n",
       "       'value': 0.520044,\n",
       "       'left': 1.209557,\n",
       "       'right': {'feature': 0,\n",
       "        'value': 0.518735,\n",
       "        'left': 0.961983,\n",
       "        'right': 1.037179}}}},\n",
       "    'right': {'feature': 0,\n",
       "     'value': 0.514563,\n",
       "     'left': 1.493586,\n",
       "     'right': {'feature': 0,\n",
       "      'value': 0.50794,\n",
       "      'left': 1.156648,\n",
       "      'right': 1.107265}}}}},\n",
       " 'right': {'feature': 0,\n",
       "  'value': 0.343479,\n",
       "  'left': {'feature': 0,\n",
       "   'value': 0.406649,\n",
       "   'left': {'feature': 0,\n",
       "    'value': 0.41023,\n",
       "    'left': {'feature': 0,\n",
       "     'value': 0.458121,\n",
       "     'left': {'feature': 0,\n",
       "      'value': 0.475976,\n",
       "      'left': -0.097791,\n",
       "      'right': {'feature': 0,\n",
       "       'value': 0.465625,\n",
       "       'left': -0.163707,\n",
       "       'right': -0.15294}},\n",
       "     'right': {'feature': 0,\n",
       "      'value': 0.429664,\n",
       "      'left': {'feature': 0,\n",
       "       'value': 0.44928,\n",
       "       'left': -0.061456,\n",
       "       'right': {'feature': 0,\n",
       "        'value': 0.448656,\n",
       "        'left': 0.069098,\n",
       "        'right': {'feature': 0,\n",
       "         'value': 0.438367,\n",
       "         'left': 0.026974,\n",
       "         'right': 0.034014}}},\n",
       "      'right': -0.188659}},\n",
       "    'right': 0.331722},\n",
       "   'right': {'feature': 0,\n",
       "    'value': 0.355688,\n",
       "    'left': {'feature': 0,\n",
       "     'value': 0.362314,\n",
       "     'left': {'feature': 0,\n",
       "      'value': 0.377597,\n",
       "      'left': {'feature': 0,\n",
       "       'value': 0.401152,\n",
       "       'left': -0.366317,\n",
       "       'right': {'feature': 0,\n",
       "        'value': 0.378595,\n",
       "        'left': -0.12164,\n",
       "        'right': -0.296094}},\n",
       "      'right': {'feature': 0,\n",
       "       'value': 0.377201,\n",
       "       'left': 0.088505,\n",
       "       'right': -0.24355}},\n",
       "     'right': {'feature': 0,\n",
       "      'value': 0.360323,\n",
       "      'left': -0.556464,\n",
       "      'right': -0.20483}},\n",
       "    'right': {'feature': 0,\n",
       "     'value': 0.343554,\n",
       "     'left': {'feature': 0,\n",
       "      'value': 0.347837,\n",
       "      'left': {'feature': 0,\n",
       "       'value': 0.348013,\n",
       "       'left': -0.119399,\n",
       "       'right': 0.048939},\n",
       "      'right': {'feature': 0,\n",
       "       'value': 0.344102,\n",
       "       'left': {'feature': 0,\n",
       "        'value': 0.346986,\n",
       "        'left': -0.153405,\n",
       "        'right': -0.150389},\n",
       "       'right': -0.061539}},\n",
       "     'right': -0.3717}}},\n",
       "  'right': {'feature': 0,\n",
       "   'value': 0.325412,\n",
       "   'left': {'feature': 0,\n",
       "    'value': 0.3371,\n",
       "    'left': {'feature': 0,\n",
       "     'value': 0.339563,\n",
       "     'left': 0.175264,\n",
       "     'right': 0.206783},\n",
       "    'right': {'feature': 0,\n",
       "     'value': 0.332982,\n",
       "     'left': 0.026332,\n",
       "     'right': 0.210084}},\n",
       "   'right': {'feature': 0,\n",
       "    'value': 0.048014,\n",
       "    'left': {'feature': 0,\n",
       "     'value': 0.081931,\n",
       "     'left': {'feature': 0,\n",
       "      'value': 0.188218,\n",
       "      'left': {'feature': 0,\n",
       "       'value': 0.23807,\n",
       "       'left': {'feature': 0,\n",
       "        'value': 0.242204,\n",
       "        'left': {'feature': 0,\n",
       "         'value': 0.323181,\n",
       "         'left': -0.219245,\n",
       "         'right': {'feature': 0,\n",
       "          'value': 0.314924,\n",
       "          'left': 0.180811,\n",
       "          'right': {'feature': 0,\n",
       "           'value': 0.27394,\n",
       "           'left': {'feature': 0,\n",
       "            'value': 0.278661,\n",
       "            'left': {'feature': 0,\n",
       "             'value': 0.280738,\n",
       "             'left': {'feature': 0,\n",
       "              'value': 0.302001,\n",
       "              'left': {'feature': 0,\n",
       "               'value': 0.306964,\n",
       "               'left': -0.001952,\n",
       "               'right': {'feature': 0,\n",
       "                'value': 0.30554,\n",
       "                'left': -0.177321,\n",
       "                'right': {'feature': 0,\n",
       "                 'value': 0.302217,\n",
       "                 'left': -0.115991,\n",
       "                 'right': -0.14865}}},\n",
       "              'right': {'feature': 0,\n",
       "               'value': 0.295511,\n",
       "               'left': 0.317135,\n",
       "               'right': 0.002882}},\n",
       "             'right': -0.22888},\n",
       "            'right': 0.253628},\n",
       "           'right': {'feature': 0,\n",
       "            'value': 0.268857,\n",
       "            'left': {'feature': 0,\n",
       "             'value': 0.273147,\n",
       "             'left': -0.085713,\n",
       "             'right': {'feature': 0,\n",
       "              'value': 0.269681,\n",
       "              'left': -0.455219,\n",
       "              'right': -0.165971}},\n",
       "            'right': {'feature': 0,\n",
       "             'value': 0.252649,\n",
       "             'left': 0.073447,\n",
       "             'right': {'feature': 0,\n",
       "              'value': 0.250744,\n",
       "              'left': -0.055613,\n",
       "              'right': {'feature': 0,\n",
       "               'value': 0.243909,\n",
       "               'left': 0.046297,\n",
       "               'right': -0.029467}}}}}}},\n",
       "        'right': 0.209359},\n",
       "       'right': {'feature': 0,\n",
       "        'value': 0.210334,\n",
       "        'left': {'feature': 0,\n",
       "         'value': 0.233115,\n",
       "         'left': -0.358459,\n",
       "         'right': -0.348147},\n",
       "        'right': {'feature': 0,\n",
       "         'value': 0.193641,\n",
       "         'left': {'feature': 0,\n",
       "          'value': 0.203693,\n",
       "          'left': -0.006899,\n",
       "          'right': {'feature': 0,\n",
       "           'value': 0.196005,\n",
       "           'left': {'feature': 0,\n",
       "            'value': 0.202054,\n",
       "            'left': -0.064036,\n",
       "            'right': -0.087744},\n",
       "           'right': -0.048847}},\n",
       "         'right': -0.327589}}},\n",
       "      'right': {'feature': 0,\n",
       "       'value': 0.1333,\n",
       "       'left': {'feature': 0,\n",
       "        'value': 0.146366,\n",
       "        'left': {'feature': 0,\n",
       "         'value': 0.148049,\n",
       "         'left': {'feature': 0,\n",
       "          'value': 0.180506,\n",
       "          'left': {'feature': 0,\n",
       "           'value': 0.18351,\n",
       "           'left': 0.113685,\n",
       "           'right': 0.184843},\n",
       "          'right': {'feature': 0,\n",
       "           'value': 0.152324,\n",
       "           'left': 0.103676,\n",
       "           'right': 0.132858}},\n",
       "         'right': 0.204298},\n",
       "        'right': {'feature': 0,\n",
       "         'value': 0.145809,\n",
       "         'left': 0.034283,\n",
       "         'right': 0.136979}},\n",
       "       'right': {'feature': 0,\n",
       "        'value': 0.130962,\n",
       "        'left': {'feature': 0,\n",
       "         'value': 0.132543,\n",
       "         'left': -0.223143,\n",
       "         'right': -0.329372},\n",
       "        'right': {'feature': 0,\n",
       "         'value': 0.118156,\n",
       "         'left': {'feature': 0,\n",
       "          'value': 0.129061,\n",
       "          'left': {'feature': 0,\n",
       "           'value': 0.130052,\n",
       "           'left': 0.184241,\n",
       "           'right': -0.026167},\n",
       "          'right': 0.305107},\n",
       "         'right': {'feature': 0,\n",
       "          'value': 0.096994,\n",
       "          'left': {'feature': 0,\n",
       "           'value': 0.098016,\n",
       "           'left': {'feature': 0,\n",
       "            'value': 0.101149,\n",
       "            'left': -0.077409,\n",
       "            'right': {'feature': 0,\n",
       "             'value': 0.099142,\n",
       "             'left': 0.068834,\n",
       "             'right': 0.02528}},\n",
       "           'right': -0.33276},\n",
       "          'right': {'feature': 0,\n",
       "           'value': 0.091358,\n",
       "           'left': 0.227167,\n",
       "           'right': {'feature': 0,\n",
       "            'value': 0.084248,\n",
       "            'left': 0.099935,\n",
       "            'right': -0.019547}}}}}}},\n",
       "     'right': {'feature': 0,\n",
       "      'value': 0.071769,\n",
       "      'left': {'feature': 0,\n",
       "       'value': 0.074795,\n",
       "       'left': -0.269756,\n",
       "       'right': {'feature': 0,\n",
       "        'value': 0.072243,\n",
       "        'left': -0.349692,\n",
       "        'right': -0.420983}},\n",
       "      'right': {'feature': 0,\n",
       "       'value': 0.065615,\n",
       "       'left': {'feature': 0,\n",
       "        'value': 0.066172,\n",
       "        'left': -0.110946,\n",
       "        'right': 0.052439},\n",
       "       'right': -0.30697}}},\n",
       "    'right': {'feature': 0,\n",
       "     'value': 0.014083,\n",
       "     'left': {'feature': 0,\n",
       "      'value': 0.036492,\n",
       "      'left': 0.064496,\n",
       "      'right': {'feature': 0,\n",
       "       'value': 0.036098,\n",
       "       'left': 0.408155,\n",
       "       'right': 0.155096}},\n",
       "     'right': {'feature': 0,\n",
       "      'value': 0.009849,\n",
       "      'left': -0.132525,\n",
       "      'right': {'feature': 0,\n",
       "       'value': 0.008307,\n",
       "       'left': 0.056594,\n",
       "       'right': {'feature': 0,\n",
       "        'value': 0.000234,\n",
       "        'left': {'feature': 0,\n",
       "         'value': 0.007044,\n",
       "         'left': 0.069976,\n",
       "         'right': 0.09415},\n",
       "        'right': 0.060903}}}}}}}}"
      ]
     },
     "execution_count": 8,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "regTrees.createTree(np.array(myDat),ops=(1,0))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'feature': 0,\n",
       " 'value': 0.499171,\n",
       " 'left': {'feature': 0,\n",
       "  'value': 0.729397,\n",
       "  'left': {'feature': 0,\n",
       "   'value': 0.952833,\n",
       "   'left': {'feature': 0,\n",
       "    'value': 0.965969,\n",
       "    'left': {'feature': 0,\n",
       "     'value': 0.968621,\n",
       "     'left': 86.399637,\n",
       "     'right': 98.648346},\n",
       "    'right': {'feature': 0,\n",
       "     'value': 0.956951,\n",
       "     'left': {'feature': 0,\n",
       "      'value': 0.958512,\n",
       "      'left': {'feature': 0,\n",
       "       'value': 0.960398,\n",
       "       'left': 112.386764,\n",
       "       'right': 123.559747},\n",
       "      'right': 135.837013},\n",
       "     'right': {'feature': 0,\n",
       "      'value': 0.953902,\n",
       "      'left': {'feature': 0,\n",
       "       'value': 0.954711,\n",
       "       'left': 82.016541,\n",
       "       'right': 100.935789},\n",
       "      'right': 130.92648}}},\n",
       "   'right': {'feature': 0,\n",
       "    'value': 0.759504,\n",
       "    'left': {'feature': 0,\n",
       "     'value': 0.763328,\n",
       "     'left': {'feature': 0,\n",
       "      'value': 0.769043,\n",
       "      'left': {'feature': 0,\n",
       "       'value': 0.790312,\n",
       "       'left': {'feature': 0,\n",
       "        'value': 0.806158,\n",
       "        'left': {'feature': 0,\n",
       "         'value': 0.815215,\n",
       "         'left': {'feature': 0,\n",
       "          'value': 0.833026,\n",
       "          'left': {'feature': 0,\n",
       "           'value': 0.841547,\n",
       "           'left': {'feature': 0,\n",
       "            'value': 0.841625,\n",
       "            'left': {'feature': 0,\n",
       "             'value': 0.944221,\n",
       "             'left': {'feature': 0,\n",
       "              'value': 0.948822,\n",
       "              'left': {'feature': 0,\n",
       "               'value': 0.949198,\n",
       "               'left': {'feature': 0,\n",
       "                'value': 0.952377,\n",
       "                'left': 100.649591,\n",
       "                'right': 73.520802},\n",
       "               'right': 105.752508},\n",
       "              'right': 69.318649},\n",
       "             'right': {'feature': 0,\n",
       "              'value': 0.85497,\n",
       "              'left': {'feature': 0,\n",
       "               'value': 0.936524,\n",
       "               'left': {'feature': 0,\n",
       "                'value': 0.937766,\n",
       "                'left': 100.120253,\n",
       "                'right': 119.949824},\n",
       "               'right': {'feature': 0,\n",
       "                'value': 0.934853,\n",
       "                'left': 65.548418,\n",
       "                'right': {'feature': 0,\n",
       "                 'value': 0.925782,\n",
       "                 'left': 115.753994,\n",
       "                 'right': {'feature': 0,\n",
       "                  'value': 0.910975,\n",
       "                  'left': {'feature': 0,\n",
       "                   'value': 0.912161,\n",
       "                   'left': {'feature': 0,\n",
       "                    'value': 0.915263,\n",
       "                    'left': 92.074619,\n",
       "                    'right': 96.71761},\n",
       "                   'right': 85.005351},\n",
       "                  'right': {'feature': 0,\n",
       "                   'value': 0.901444,\n",
       "                   'left': {'feature': 0,\n",
       "                    'value': 0.908629,\n",
       "                    'left': 106.814667,\n",
       "                    'right': 118.513475},\n",
       "                   'right': {'feature': 0,\n",
       "                    'value': 0.901421,\n",
       "                    'left': 87.300625,\n",
       "                    'right': {'feature': 0,\n",
       "                     'value': 0.892999,\n",
       "                     'left': {'feature': 0,\n",
       "                      'value': 0.900699,\n",
       "                      'left': 100.133819,\n",
       "                      'right': 108.094934},\n",
       "                     'right': {'feature': 0,\n",
       "                      'value': 0.888426,\n",
       "                      'left': 82.436686,\n",
       "                      'right': {'feature': 0,\n",
       "                       'value': 0.872199,\n",
       "                       'left': {'feature': 0,\n",
       "                        'value': 0.883615,\n",
       "                        'left': {'feature': 0,\n",
       "                         'value': 0.885676,\n",
       "                         'left': 94.896354,\n",
       "                         'right': 108.045948},\n",
       "                        'right': 95.617948},\n",
       "                       'right': {'feature': 0,\n",
       "                        'value': 0.866451,\n",
       "                        'left': 111.552716,\n",
       "                        'right': {'feature': 0,\n",
       "                         'value': 0.856421,\n",
       "                         'left': 94.402102,\n",
       "                         'right': 107.166848}}}}}}}}}}},\n",
       "              'right': {'feature': 0,\n",
       "               'value': 0.84294,\n",
       "               'left': {'feature': 0,\n",
       "                'value': 0.847219,\n",
       "                'left': 89.20993,\n",
       "                'right': 76.240984},\n",
       "               'right': 95.893131}}},\n",
       "            'right': 60.552308},\n",
       "           'right': {'feature': 0,\n",
       "            'value': 0.838587,\n",
       "            'left': 115.669032,\n",
       "            'right': 134.089674}},\n",
       "          'right': {'feature': 0,\n",
       "           'value': 0.823848,\n",
       "           'left': 76.723835,\n",
       "           'right': {'feature': 0,\n",
       "            'value': 0.819722,\n",
       "            'left': 59.342323,\n",
       "            'right': 70.054508}}},\n",
       "         'right': {'feature': 0,\n",
       "          'value': 0.811602,\n",
       "          'left': 118.319942,\n",
       "          'right': {'feature': 0,\n",
       "           'value': 0.811363,\n",
       "           'left': 99.841379,\n",
       "           'right': 112.981216}}},\n",
       "        'right': {'feature': 0,\n",
       "         'value': 0.799873,\n",
       "         'left': 62.877698,\n",
       "         'right': {'feature': 0,\n",
       "          'value': 0.798198,\n",
       "          'left': 91.368473,\n",
       "          'right': 76.853728}}},\n",
       "       'right': {'feature': 0,\n",
       "        'value': 0.786865,\n",
       "        'left': {'feature': 0,\n",
       "         'value': 0.787755,\n",
       "         'left': 110.15973,\n",
       "         'right': 118.642009},\n",
       "        'right': {'feature': 0,\n",
       "         'value': 0.785574,\n",
       "         'left': 100.598825,\n",
       "         'right': {'feature': 0,\n",
       "          'value': 0.777582,\n",
       "          'left': 107.024467,\n",
       "          'right': 100.838446}}}},\n",
       "      'right': 64.041941},\n",
       "     'right': 115.199195},\n",
       "    'right': {'feature': 0,\n",
       "     'value': 0.740859,\n",
       "     'left': {'feature': 0,\n",
       "      'value': 0.757527,\n",
       "      'left': 81.106762,\n",
       "      'right': 63.549854},\n",
       "     'right': {'feature': 0,\n",
       "      'value': 0.731636,\n",
       "      'left': 93.773929,\n",
       "      'right': 73.912028}}}},\n",
       "  'right': {'feature': 0,\n",
       "   'value': 0.640515,\n",
       "   'left': {'feature': 0,\n",
       "    'value': 0.642373,\n",
       "    'left': {'feature': 0,\n",
       "     'value': 0.642707,\n",
       "     'left': {'feature': 0,\n",
       "      'value': 0.665329,\n",
       "      'left': {'feature': 0,\n",
       "       'value': 0.706961,\n",
       "       'left': {'feature': 0,\n",
       "        'value': 0.70889,\n",
       "        'left': {'feature': 0,\n",
       "         'value': 0.716211,\n",
       "         'left': 110.90283,\n",
       "         'right': {'feature': 0,\n",
       "          'value': 0.710234,\n",
       "          'left': 103.345308,\n",
       "          'right': 108.553919}},\n",
       "        'right': 135.416767},\n",
       "       'right': {'feature': 0,\n",
       "        'value': 0.698472,\n",
       "        'left': {'feature': 0,\n",
       "         'value': 0.69892,\n",
       "         'left': {'feature': 0,\n",
       "          'value': 0.699873,\n",
       "          'left': 105.621287,\n",
       "          'right': 115.586605},\n",
       "         'right': 92.470636},\n",
       "        'right': {'feature': 0,\n",
       "         'value': 0.689099,\n",
       "         'left': 120.521925,\n",
       "         'right': {'feature': 0,\n",
       "          'value': 0.666452,\n",
       "          'left': {'feature': 0,\n",
       "           'value': 0.667851,\n",
       "           'left': 111.3726415,\n",
       "           'right': 92.449664},\n",
       "          'right': {'feature': 0,\n",
       "           'value': 0.665652,\n",
       "           'left': 120.014736,\n",
       "           'right': 105.547997}}}}},\n",
       "      'right': {'feature': 0,\n",
       "       'value': 0.661073,\n",
       "       'left': 121.980607,\n",
       "       'right': {'feature': 0,\n",
       "        'value': 0.652462,\n",
       "        'left': 115.687524,\n",
       "        'right': 112.715799}}},\n",
       "     'right': 82.500766},\n",
       "    'right': 140.613941},\n",
       "   'right': {'feature': 0,\n",
       "    'value': 0.613004,\n",
       "    'left': {'feature': 0,\n",
       "     'value': 0.623909,\n",
       "     'left': {'feature': 0,\n",
       "      'value': 0.628061,\n",
       "      'left': {'feature': 0,\n",
       "       'value': 0.637999,\n",
       "       'left': 82.713621,\n",
       "       'right': 92.650955},\n",
       "      'right': {'feature': 0,\n",
       "       'value': 0.624827,\n",
       "       'left': 117.628346,\n",
       "       'right': 105.970743}},\n",
       "     'right': {'feature': 0,\n",
       "      'value': 0.618868,\n",
       "      'left': 87.181863,\n",
       "      'right': 76.917665}},\n",
       "    'right': {'feature': 0,\n",
       "     'value': 0.606417,\n",
       "     'left': 168.180746,\n",
       "     'right': {'feature': 0,\n",
       "      'value': 0.513332,\n",
       "      'left': {'feature': 0,\n",
       "       'value': 0.533511,\n",
       "       'left': {'feature': 0,\n",
       "        'value': 0.548539,\n",
       "        'left': {'feature': 0,\n",
       "         'value': 0.553797,\n",
       "         'left': {'feature': 0,\n",
       "          'value': 0.560301,\n",
       "          'left': {'feature': 0,\n",
       "           'value': 0.599142,\n",
       "           'left': 93.521396,\n",
       "           'right': {'feature': 0,\n",
       "            'value': 0.589806,\n",
       "            'left': 130.378529,\n",
       "            'right': {'feature': 0,\n",
       "             'value': 0.582311,\n",
       "             'left': {'feature': 0,\n",
       "              'value': 0.585413,\n",
       "              'left': 98.674874,\n",
       "              'right': 125.295113},\n",
       "             'right': {'feature': 0,\n",
       "              'value': 0.571214,\n",
       "              'left': 82.589328,\n",
       "              'right': {'feature': 0,\n",
       "               'value': 0.569327,\n",
       "               'left': 114.872056,\n",
       "               'right': 108.435392}}}}},\n",
       "          'right': 82.903945},\n",
       "         'right': {'feature': 0,\n",
       "          'value': 0.549814,\n",
       "          'left': 120.857321,\n",
       "          'right': 137.267576}},\n",
       "        'right': {'feature': 0,\n",
       "         'value': 0.546601,\n",
       "         'left': 83.114502,\n",
       "         'right': {'feature': 0,\n",
       "          'value': 0.537834,\n",
       "          'left': 97.3405265,\n",
       "          'right': 90.995536}}},\n",
       "       'right': {'feature': 0,\n",
       "        'value': 0.51915,\n",
       "        'left': {'feature': 0,\n",
       "         'value': 0.531944,\n",
       "         'left': 129.766743,\n",
       "         'right': 124.795495},\n",
       "        'right': 116.176162}},\n",
       "      'right': {'feature': 0,\n",
       "       'value': 0.508548,\n",
       "       'left': 101.075609,\n",
       "       'right': {'feature': 0,\n",
       "        'value': 0.508542,\n",
       "        'left': 93.292829,\n",
       "        'right': 96.403373}}}}}}},\n",
       " 'right': {'feature': 0,\n",
       "  'value': 0.457563,\n",
       "  'left': {'feature': 0,\n",
       "   'value': 0.465561,\n",
       "   'left': {'feature': 0,\n",
       "    'value': 0.467383,\n",
       "    'left': {'feature': 0,\n",
       "     'value': 0.483803,\n",
       "     'left': {'feature': 0,\n",
       "      'value': 0.487381,\n",
       "      'left': {'feature': 0,\n",
       "       'value': 0.487537,\n",
       "       'left': 11.924204,\n",
       "       'right': 5.149336},\n",
       "      'right': 27.729263},\n",
       "     'right': 5.224234},\n",
       "    'right': {'feature': 0,\n",
       "     'value': 0.46568,\n",
       "     'left': -9.712925,\n",
       "     'right': -23.777531}},\n",
       "   'right': {'feature': 0,\n",
       "    'value': 0.463241,\n",
       "    'left': 30.051931,\n",
       "    'right': 17.171057}},\n",
       "  'right': {'feature': 0,\n",
       "   'value': 0.455761,\n",
       "   'left': -34.044555,\n",
       "   'right': {'feature': 0,\n",
       "    'value': 0.126833,\n",
       "    'left': {'feature': 0,\n",
       "     'value': 0.130626,\n",
       "     'left': {'feature': 0,\n",
       "      'value': 0.382037,\n",
       "      'left': {'feature': 0,\n",
       "       'value': 0.388789,\n",
       "       'left': {'feature': 0,\n",
       "        'value': 0.437652,\n",
       "        'left': {'feature': 0,\n",
       "         'value': 0.454312,\n",
       "         'left': {'feature': 0,\n",
       "          'value': 0.454375,\n",
       "          'left': 9.841938,\n",
       "          'right': 3.043912},\n",
       "         'right': {'feature': 0,\n",
       "          'value': 0.446196,\n",
       "          'left': {'feature': 0,\n",
       "           'value': 0.451087,\n",
       "           'left': -20.360067,\n",
       "           'right': -28.724685},\n",
       "          'right': -5.108172}},\n",
       "        'right': {'feature': 0,\n",
       "         'value': 0.412516,\n",
       "         'left': {'feature': 0,\n",
       "          'value': 0.418943,\n",
       "          'left': {'feature': 0,\n",
       "           'value': 0.426711,\n",
       "           'left': {'feature': 0,\n",
       "            'value': 0.428582,\n",
       "            'left': 19.745224,\n",
       "            'right': 15.224266},\n",
       "           'right': -21.594268},\n",
       "          'right': 44.161493},\n",
       "         'right': {'feature': 0,\n",
       "          'value': 0.403228,\n",
       "          'left': -26.419289,\n",
       "          'right': {'feature': 0,\n",
       "           'value': 0.391609,\n",
       "           'left': -1.729244,\n",
       "           'right': 3.001104}}}},\n",
       "       'right': {'feature': 0,\n",
       "        'value': 0.385021,\n",
       "        'left': 21.578007,\n",
       "        'right': 24.816941}},\n",
       "      'right': {'feature': 0,\n",
       "       'value': 0.335182,\n",
       "       'left': {'feature': 0,\n",
       "        'value': 0.370042,\n",
       "        'left': {'feature': 0,\n",
       "         'value': 0.378965,\n",
       "         'left': -29.007783,\n",
       "         'right': {'feature': 0,\n",
       "          'value': 0.373501,\n",
       "          'left': {'feature': 0,\n",
       "           'value': 0.377383,\n",
       "           'left': 13.583555,\n",
       "           'right': 5.241196},\n",
       "          'right': -8.228297}},\n",
       "        'right': {'feature': 0,\n",
       "         'value': 0.35679,\n",
       "         'left': -32.124495,\n",
       "         'right': {'feature': 0,\n",
       "          'value': 0.350725,\n",
       "          'left': {'feature': 0,\n",
       "           'value': 0.351478,\n",
       "           'left': -19.526539,\n",
       "           'right': -0.461116},\n",
       "          'right': {'feature': 0,\n",
       "           'value': 0.350065,\n",
       "           'left': -40.086564,\n",
       "           'right': {'feature': 0,\n",
       "            'value': 0.342761,\n",
       "            'left': -1.319852,\n",
       "            'right': {'feature': 0,\n",
       "             'value': 0.342155,\n",
       "             'left': -31.584855,\n",
       "             'right': {'feature': 0,\n",
       "              'value': 0.3417,\n",
       "              'left': -16.930416,\n",
       "              'right': -23.547711}}}}}}},\n",
       "       'right': {'feature': 0,\n",
       "        'value': 0.324274,\n",
       "        'left': {'feature': 0,\n",
       "         'value': 0.32889,\n",
       "         'left': {'feature': 0,\n",
       "          'value': 0.331364,\n",
       "          'left': {'feature': 0,\n",
       "           'value': 0.3349,\n",
       "           'left': 2.768225,\n",
       "           'right': 18.97665},\n",
       "          'right': -1.290825},\n",
       "         'right': 39.783113},\n",
       "        'right': {'feature': 0,\n",
       "         'value': 0.309133,\n",
       "         'left': {'feature': 0,\n",
       "          'value': 0.310956,\n",
       "          'left': {'feature': 0,\n",
       "           'value': 0.318309,\n",
       "           'left': -13.189243,\n",
       "           'right': -27.605424},\n",
       "          'right': -49.939516},\n",
       "         'right': {'feature': 0,\n",
       "          'value': 0.131833,\n",
       "          'left': {'feature': 0,\n",
       "           'value': 0.138619,\n",
       "           'left': {'feature': 0,\n",
       "            'value': 0.156067,\n",
       "            'left': {'feature': 0,\n",
       "             'value': 0.166765,\n",
       "             'left': {'feature': 0,\n",
       "              'value': 0.193282,\n",
       "              'left': {'feature': 0,\n",
       "               'value': 0.211633,\n",
       "               'left': {'feature': 0,\n",
       "                'value': 0.228473,\n",
       "                'left': {'feature': 0,\n",
       "                 'value': 0.25807,\n",
       "                 'left': {'feature': 0,\n",
       "                  'value': 0.284794,\n",
       "                  'left': {'feature': 0,\n",
       "                   'value': 0.300318,\n",
       "                   'left': 8.814725,\n",
       "                   'right': {'feature': 0,\n",
       "                    'value': 0.297107,\n",
       "                    'left': -18.051318,\n",
       "                    'right': {'feature': 0,\n",
       "                     'value': 0.295993,\n",
       "                     'left': -1.798377,\n",
       "                     'right': -14.689945999999999}}},\n",
       "                  'right': {'feature': 0,\n",
       "                   'value': 0.273863,\n",
       "                   'left': 35.623746,\n",
       "                   'right': {'feature': 0,\n",
       "                    'value': 0.264926,\n",
       "                    'left': -9.457556,\n",
       "                    'right': 3.919251}}},\n",
       "                 'right': {'feature': 0,\n",
       "                  'value': 0.228628,\n",
       "                  'left': {'feature': 0,\n",
       "                   'value': 0.228751,\n",
       "                   'left': {'feature': 0,\n",
       "                    'value': 0.232802,\n",
       "                    'left': -20.425137,\n",
       "                    'right': 1.222318},\n",
       "                   'right': -30.812912},\n",
       "                  'right': -2.266273}},\n",
       "                'right': {'feature': 0,\n",
       "                 'value': 0.222271,\n",
       "                 'left': {'feature': 0,\n",
       "                  'value': 0.2232,\n",
       "                  'left': 19.425158,\n",
       "                  'right': 15.501642},\n",
       "                 'right': {'feature': 0,\n",
       "                  'value': 0.218321,\n",
       "                  'left': -9.255852,\n",
       "                  'right': {'feature': 0,\n",
       "                   'value': 0.217214,\n",
       "                   'left': 1.410768,\n",
       "                   'right': -3.958752}}}},\n",
       "               'right': {'feature': 0,\n",
       "                'value': 0.202161,\n",
       "                'left': {'feature': 0,\n",
       "                 'value': 0.203993,\n",
       "                 'left': {'feature': 0,\n",
       "                  'value': 0.206207,\n",
       "                  'left': -8.332207,\n",
       "                  'right': -12.619036},\n",
       "                 'right': -22.379119},\n",
       "                'right': -2.6781805}},\n",
       "              'right': {'feature': 0,\n",
       "               'value': 0.176523,\n",
       "               'left': 18.208423,\n",
       "               'right': 0.946348}},\n",
       "             'right': {'feature': 0,\n",
       "              'value': 0.156273,\n",
       "              'left': {'feature': 0,\n",
       "               'value': 0.164134,\n",
       "               'left': {'feature': 0,\n",
       "                'value': 0.166431,\n",
       "                'left': -14.740059,\n",
       "                'right': -6.512506},\n",
       "               'right': -27.405211},\n",
       "              'right': 0.225886}},\n",
       "            'right': 7.4470665},\n",
       "           'right': -29.087463},\n",
       "          'right': 22.478291}}}}},\n",
       "     'right': -39.524461},\n",
       "    'right': {'feature': 0,\n",
       "     'value': 0.124723,\n",
       "     'left': 22.891675,\n",
       "     'right': {'feature': 0,\n",
       "      'value': 0.085111,\n",
       "      'left': {'feature': 0,\n",
       "       'value': 0.108801,\n",
       "       'left': {'feature': 0,\n",
       "        'value': 0.11515,\n",
       "        'left': -1.402796,\n",
       "        'right': 13.795828},\n",
       "       'right': {'feature': 0,\n",
       "        'value': 0.10796,\n",
       "        'left': -16.106164,\n",
       "        'right': {'feature': 0,\n",
       "         'value': 0.085873,\n",
       "         'left': -1.293195,\n",
       "         'right': -10.137104}}},\n",
       "      'right': {'feature': 0,\n",
       "       'value': 0.084661,\n",
       "       'left': 37.820659,\n",
       "       'right': {'feature': 0,\n",
       "        'value': 0.080061,\n",
       "        'left': -24.132226,\n",
       "        'right': {'feature': 0,\n",
       "         'value': 0.068373,\n",
       "         'left': {'feature': 0,\n",
       "          'value': 0.079632,\n",
       "          'left': 2.229873,\n",
       "          'right': 29.420068},\n",
       "         'right': {'feature': 0,\n",
       "          'value': 0.061219,\n",
       "          'left': -15.160836,\n",
       "          'right': {'feature': 0,\n",
       "           'value': 0.044737,\n",
       "           'left': {'feature': 0,\n",
       "            'value': 0.053764,\n",
       "            'left': {'feature': 0,\n",
       "             'value': 0.055862,\n",
       "             'left': 6.695567,\n",
       "             'right': -3.131497},\n",
       "            'right': -13.731698},\n",
       "           'right': {'feature': 0,\n",
       "            'value': 0.028546,\n",
       "            'left': {'feature': 0,\n",
       "             'value': 0.039914,\n",
       "             'left': 3.855393,\n",
       "             'right': 11.220099},\n",
       "            'right': {'feature': 0,\n",
       "             'value': 0.000256,\n",
       "             'left': -8.377094,\n",
       "             'right': 9.668106}}}}}}}}}}}}}"
      ]
     },
     "execution_count": 9,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "myDat2=regTrees.loadDataSet('ex2.txt')\n",
    "regTrees.createTree(np.array(myDat2))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'feature': 0,\n",
       " 'value': 0.499171,\n",
       " 'left': 101.35815937735848,\n",
       " 'right': -2.637719329787234}"
      ]
     },
     "execution_count": 10,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "regTrees.createTree(np.array(myDat2), ops=(4, 10000))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# prunt"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "merging\n",
      "merging\n",
      "merging\n",
      "merging\n",
      "merging\n",
      "merging\n",
      "merging\n",
      "merging\n",
      "merging\n",
      "merging\n",
      "merging\n",
      "merging\n",
      "merging\n",
      "merging\n",
      "merging\n",
      "merging\n",
      "merging\n",
      "merging\n",
      "merging\n",
      "merging\n",
      "merging\n",
      "merging\n",
      "merging\n",
      "merging\n",
      "merging\n",
      "merging\n",
      "merging\n",
      "merging\n",
      "merging\n",
      "merging\n",
      "merging\n",
      "merging\n",
      "merging\n",
      "merging\n",
      "merging\n",
      "merging\n",
      "merging\n",
      "merging\n",
      "merging\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "{'feature': 0,\n",
       " 'value': 0.499171,\n",
       " 'left': {'feature': 0,\n",
       "  'value': 0.729397,\n",
       "  'left': {'feature': 0,\n",
       "   'value': 0.952833,\n",
       "   'left': {'feature': 0,\n",
       "    'value': 0.965969,\n",
       "    'left': {'feature': 0,\n",
       "     'value': 0.968621,\n",
       "     'left': 86.399637,\n",
       "     'right': 98.648346},\n",
       "    'right': {'feature': 0,\n",
       "     'value': 0.956951,\n",
       "     'left': {'feature': 0,\n",
       "      'value': 0.958512,\n",
       "      'left': {'feature': 0,\n",
       "       'value': 0.960398,\n",
       "       'left': 112.386764,\n",
       "       'right': 123.559747},\n",
       "      'right': 135.837013},\n",
       "     'right': 111.2013225}},\n",
       "   'right': {'feature': 0,\n",
       "    'value': 0.759504,\n",
       "    'left': {'feature': 0,\n",
       "     'value': 0.763328,\n",
       "     'left': {'feature': 0,\n",
       "      'value': 0.769043,\n",
       "      'left': {'feature': 0,\n",
       "       'value': 0.790312,\n",
       "       'left': {'feature': 0,\n",
       "        'value': 0.806158,\n",
       "        'left': {'feature': 0,\n",
       "         'value': 0.815215,\n",
       "         'left': {'feature': 0,\n",
       "          'value': 0.833026,\n",
       "          'left': {'feature': 0,\n",
       "           'value': 0.841547,\n",
       "           'left': {'feature': 0,\n",
       "            'value': 0.841625,\n",
       "            'left': {'feature': 0,\n",
       "             'value': 0.944221,\n",
       "             'left': {'feature': 0,\n",
       "              'value': 0.948822,\n",
       "              'left': {'feature': 0,\n",
       "               'value': 0.949198,\n",
       "               'left': {'feature': 0,\n",
       "                'value': 0.952377,\n",
       "                'left': 100.649591,\n",
       "                'right': 73.520802},\n",
       "               'right': 105.752508},\n",
       "              'right': 69.318649},\n",
       "             'right': {'feature': 0,\n",
       "              'value': 0.85497,\n",
       "              'left': {'feature': 0,\n",
       "               'value': 0.936524,\n",
       "               'left': {'feature': 0,\n",
       "                'value': 0.937766,\n",
       "                'left': 100.120253,\n",
       "                'right': 119.949824},\n",
       "               'right': {'feature': 0,\n",
       "                'value': 0.934853,\n",
       "                'left': 65.548418,\n",
       "                'right': {'feature': 0,\n",
       "                 'value': 0.925782,\n",
       "                 'left': 115.753994,\n",
       "                 'right': {'feature': 0,\n",
       "                  'value': 0.910975,\n",
       "                  'left': {'feature': 0,\n",
       "                   'value': 0.912161,\n",
       "                   'left': {'feature': 0,\n",
       "                    'value': 0.915263,\n",
       "                    'left': 92.074619,\n",
       "                    'right': 96.71761},\n",
       "                   'right': 85.005351},\n",
       "                  'right': {'feature': 0,\n",
       "                   'value': 0.901444,\n",
       "                   'left': {'feature': 0,\n",
       "                    'value': 0.908629,\n",
       "                    'left': 106.814667,\n",
       "                    'right': 118.513475},\n",
       "                   'right': {'feature': 0,\n",
       "                    'value': 0.901421,\n",
       "                    'left': 87.300625,\n",
       "                    'right': {'feature': 0,\n",
       "                     'value': 0.892999,\n",
       "                     'left': {'feature': 0,\n",
       "                      'value': 0.900699,\n",
       "                      'left': 100.133819,\n",
       "                      'right': {'feature': 0,\n",
       "                       'value': 0.896683,\n",
       "                       'left': 109.188248,\n",
       "                       'right': 107.00162}},\n",
       "                     'right': {'feature': 0,\n",
       "                      'value': 0.888426,\n",
       "                      'left': 82.436686,\n",
       "                      'right': {'feature': 0,\n",
       "                       'value': 0.872199,\n",
       "                       'left': {'feature': 0,\n",
       "                        'value': 0.883615,\n",
       "                        'left': 101.47115099999999,\n",
       "                        'right': {'feature': 0,\n",
       "                         'value': 0.872883,\n",
       "                         'left': 95.348184,\n",
       "                         'right': 95.887712}},\n",
       "                       'right': {'feature': 0,\n",
       "                        'value': 0.866451,\n",
       "                        'left': 111.552716,\n",
       "                        'right': {'feature': 0,\n",
       "                         'value': 0.856421,\n",
       "                         'left': 94.402102,\n",
       "                         'right': 107.166848}}}}}}}}}}},\n",
       "              'right': {'feature': 0,\n",
       "               'value': 0.84294,\n",
       "               'left': 82.725457,\n",
       "               'right': 95.893131}}},\n",
       "            'right': 60.552308},\n",
       "           'right': 124.87935300000001},\n",
       "          'right': {'feature': 0,\n",
       "           'value': 0.823848,\n",
       "           'left': 76.723835,\n",
       "           'right': {'feature': 0,\n",
       "            'value': 0.819722,\n",
       "            'left': 59.342323,\n",
       "            'right': 70.054508}}},\n",
       "         'right': 112.36561975000001},\n",
       "        'right': {'feature': 0,\n",
       "         'value': 0.799873,\n",
       "         'left': 62.877698,\n",
       "         'right': {'feature': 0,\n",
       "          'value': 0.798198,\n",
       "          'left': 91.368473,\n",
       "          'right': 76.853728}}},\n",
       "       'right': {'feature': 0,\n",
       "        'value': 0.786865,\n",
       "        'left': 114.4008695,\n",
       "        'right': 102.26514075}},\n",
       "      'right': 64.041941},\n",
       "     'right': 115.199195},\n",
       "    'right': {'feature': 0,\n",
       "     'value': 0.740859,\n",
       "     'left': {'feature': 0,\n",
       "      'value': 0.757527,\n",
       "      'left': 81.106762,\n",
       "      'right': 63.549854},\n",
       "     'right': 83.8429785}}},\n",
       "  'right': {'feature': 0,\n",
       "   'value': 0.640515,\n",
       "   'left': {'feature': 0,\n",
       "    'value': 0.642373,\n",
       "    'left': {'feature': 0,\n",
       "     'value': 0.642707,\n",
       "     'left': {'feature': 0,\n",
       "      'value': 0.665329,\n",
       "      'left': {'feature': 0,\n",
       "       'value': 0.706961,\n",
       "       'left': {'feature': 0,\n",
       "        'value': 0.70889,\n",
       "        'left': {'feature': 0,\n",
       "         'value': 0.716211,\n",
       "         'left': 110.90283,\n",
       "         'right': {'feature': 0,\n",
       "          'value': 0.710234,\n",
       "          'left': 103.345308,\n",
       "          'right': 108.553919}},\n",
       "        'right': 135.416767},\n",
       "       'right': {'feature': 0,\n",
       "        'value': 0.698472,\n",
       "        'left': {'feature': 0,\n",
       "         'value': 0.69892,\n",
       "         'left': {'feature': 0,\n",
       "          'value': 0.699873,\n",
       "          'left': {'feature': 0,\n",
       "           'value': 0.70639,\n",
       "           'left': 106.180427,\n",
       "           'right': 105.062147},\n",
       "          'right': 115.586605},\n",
       "         'right': 92.470636},\n",
       "        'right': {'feature': 0,\n",
       "         'value': 0.689099,\n",
       "         'left': 120.521925,\n",
       "         'right': {'feature': 0,\n",
       "          'value': 0.666452,\n",
       "          'left': {'feature': 0,\n",
       "           'value': 0.667851,\n",
       "           'left': {'feature': 0,\n",
       "            'value': 0.680486,\n",
       "            'left': 112.378209,\n",
       "            'right': 110.367074},\n",
       "           'right': 92.449664},\n",
       "          'right': 112.78136649999999}}}},\n",
       "      'right': {'feature': 0,\n",
       "       'value': 0.661073,\n",
       "       'left': 121.980607,\n",
       "       'right': {'feature': 0,\n",
       "        'value': 0.652462,\n",
       "        'left': 115.687524,\n",
       "        'right': 112.715799}}},\n",
       "     'right': 82.500766},\n",
       "    'right': 140.613941},\n",
       "   'right': {'feature': 0,\n",
       "    'value': 0.613004,\n",
       "    'left': {'feature': 0,\n",
       "     'value': 0.623909,\n",
       "     'left': {'feature': 0,\n",
       "      'value': 0.628061,\n",
       "      'left': 87.682288,\n",
       "      'right': 111.7995445},\n",
       "     'right': 82.04976400000001},\n",
       "    'right': {'feature': 0,\n",
       "     'value': 0.606417,\n",
       "     'left': 168.180746,\n",
       "     'right': {'feature': 0,\n",
       "      'value': 0.513332,\n",
       "      'left': {'feature': 0,\n",
       "       'value': 0.533511,\n",
       "       'left': {'feature': 0,\n",
       "        'value': 0.548539,\n",
       "        'left': {'feature': 0,\n",
       "         'value': 0.553797,\n",
       "         'left': {'feature': 0,\n",
       "          'value': 0.560301,\n",
       "          'left': {'feature': 0,\n",
       "           'value': 0.599142,\n",
       "           'left': 93.521396,\n",
       "           'right': {'feature': 0,\n",
       "            'value': 0.589806,\n",
       "            'left': 130.378529,\n",
       "            'right': {'feature': 0,\n",
       "             'value': 0.582311,\n",
       "             'left': 111.9849935,\n",
       "             'right': {'feature': 0,\n",
       "              'value': 0.571214,\n",
       "              'left': 82.589328,\n",
       "              'right': {'feature': 0,\n",
       "               'value': 0.569327,\n",
       "               'left': 114.872056,\n",
       "               'right': 108.435392}}}}},\n",
       "          'right': 82.903945},\n",
       "         'right': 129.0624485},\n",
       "        'right': {'feature': 0,\n",
       "         'value': 0.546601,\n",
       "         'left': 83.114502,\n",
       "         'right': {'feature': 0,\n",
       "          'value': 0.537834,\n",
       "          'left': 97.3405265,\n",
       "          'right': 90.995536}}},\n",
       "       'right': {'feature': 0,\n",
       "        'value': 0.51915,\n",
       "        'left': {'feature': 0,\n",
       "         'value': 0.531944,\n",
       "         'left': 129.766743,\n",
       "         'right': 124.795495},\n",
       "        'right': 116.176162}},\n",
       "      'right': {'feature': 0,\n",
       "       'value': 0.508548,\n",
       "       'left': 101.075609,\n",
       "       'right': 94.848101}}}}}},\n",
       " 'right': {'feature': 0,\n",
       "  'value': 0.457563,\n",
       "  'left': {'feature': 0,\n",
       "   'value': 0.465561,\n",
       "   'left': {'feature': 0,\n",
       "    'value': 0.467383,\n",
       "    'left': {'feature': 0,\n",
       "     'value': 0.483803,\n",
       "     'left': {'feature': 0,\n",
       "      'value': 0.487381,\n",
       "      'left': 8.53677,\n",
       "      'right': 27.729263},\n",
       "     'right': 5.224234},\n",
       "    'right': {'feature': 0,\n",
       "     'value': 0.46568,\n",
       "     'left': -9.712925,\n",
       "     'right': -23.777531}},\n",
       "   'right': {'feature': 0,\n",
       "    'value': 0.463241,\n",
       "    'left': 30.051931,\n",
       "    'right': 17.171057}},\n",
       "  'right': {'feature': 0,\n",
       "   'value': 0.455761,\n",
       "   'left': -34.044555,\n",
       "   'right': {'feature': 0,\n",
       "    'value': 0.126833,\n",
       "    'left': {'feature': 0,\n",
       "     'value': 0.130626,\n",
       "     'left': {'feature': 0,\n",
       "      'value': 0.382037,\n",
       "      'left': {'feature': 0,\n",
       "       'value': 0.388789,\n",
       "       'left': {'feature': 0,\n",
       "        'value': 0.437652,\n",
       "        'left': -4.1911745,\n",
       "        'right': {'feature': 0,\n",
       "         'value': 0.412516,\n",
       "         'left': {'feature': 0,\n",
       "          'value': 0.418943,\n",
       "          'left': -2.0547614999999997,\n",
       "          'right': 44.161493},\n",
       "         'right': -12.891679499999999}},\n",
       "       'right': 23.197474},\n",
       "      'right': {'feature': 0,\n",
       "       'value': 0.335182,\n",
       "       'left': {'feature': 0,\n",
       "        'value': 0.370042,\n",
       "        'left': {'feature': 0,\n",
       "         'value': 0.378965,\n",
       "         'left': -29.007783,\n",
       "         'right': {'feature': 0,\n",
       "          'value': 0.373501,\n",
       "          'left': {'feature': 0,\n",
       "           'value': 0.377383,\n",
       "           'left': 13.583555,\n",
       "           'right': 5.241196},\n",
       "          'right': -8.228297}},\n",
       "        'right': {'feature': 0,\n",
       "         'value': 0.35679,\n",
       "         'left': -32.124495,\n",
       "         'right': {'feature': 0,\n",
       "          'value': 0.350725,\n",
       "          'left': -9.9938275,\n",
       "          'right': -26.851234812500003}}},\n",
       "       'right': {'feature': 0,\n",
       "        'value': 0.324274,\n",
       "        'left': 22.286959625,\n",
       "        'right': {'feature': 0,\n",
       "         'value': 0.309133,\n",
       "         'left': {'feature': 0,\n",
       "          'value': 0.310956,\n",
       "          'left': -20.3973335,\n",
       "          'right': -49.939516},\n",
       "         'right': {'feature': 0,\n",
       "          'value': 0.131833,\n",
       "          'left': {'feature': 0,\n",
       "           'value': 0.138619,\n",
       "           'left': {'feature': 0,\n",
       "            'value': 0.156067,\n",
       "            'left': {'feature': 0,\n",
       "             'value': 0.166765,\n",
       "             'left': {'feature': 0,\n",
       "              'value': 0.193282,\n",
       "              'left': {'feature': 0,\n",
       "               'value': 0.211633,\n",
       "               'left': {'feature': 0,\n",
       "                'value': 0.228473,\n",
       "                'left': {'feature': 0,\n",
       "                 'value': 0.25807,\n",
       "                 'left': {'feature': 0,\n",
       "                  'value': 0.284794,\n",
       "                  'left': {'feature': 0,\n",
       "                   'value': 0.300318,\n",
       "                   'left': 8.814725,\n",
       "                   'right': {'feature': 0,\n",
       "                    'value': 0.297107,\n",
       "                    'left': -18.051318,\n",
       "                    'right': {'feature': 0,\n",
       "                     'value': 0.295993,\n",
       "                     'left': -1.798377,\n",
       "                     'right': {'feature': 0,\n",
       "                      'value': 0.290749,\n",
       "                      'left': -14.988279,\n",
       "                      'right': -14.391613}}}},\n",
       "                  'right': {'feature': 0,\n",
       "                   'value': 0.273863,\n",
       "                   'left': 35.623746,\n",
       "                   'right': {'feature': 0,\n",
       "                    'value': 0.264926,\n",
       "                    'left': -9.457556,\n",
       "                    'right': {'feature': 0,\n",
       "                     'value': 0.264639,\n",
       "                     'left': 5.280579,\n",
       "                     'right': 2.557923}}}},\n",
       "                 'right': {'feature': 0,\n",
       "                  'value': 0.228628,\n",
       "                  'left': {'feature': 0,\n",
       "                   'value': 0.228751,\n",
       "                   'left': -9.601409499999999,\n",
       "                   'right': -30.812912},\n",
       "                  'right': -2.266273}},\n",
       "                'right': 6.099239},\n",
       "               'right': {'feature': 0,\n",
       "                'value': 0.202161,\n",
       "                'left': -16.42737025,\n",
       "                'right': -2.6781805}},\n",
       "              'right': 9.5773855},\n",
       "             'right': {'feature': 0,\n",
       "              'value': 0.156273,\n",
       "              'left': {'feature': 0,\n",
       "               'value': 0.164134,\n",
       "               'left': {'feature': 0,\n",
       "                'value': 0.166431,\n",
       "                'left': -14.740059,\n",
       "                'right': -6.512506},\n",
       "               'right': -27.405211},\n",
       "              'right': 0.225886}},\n",
       "            'right': 7.4470665},\n",
       "           'right': -29.087463},\n",
       "          'right': 22.478291}}}}},\n",
       "     'right': -39.524461},\n",
       "    'right': {'feature': 0,\n",
       "     'value': 0.124723,\n",
       "     'left': 22.891675,\n",
       "     'right': {'feature': 0,\n",
       "      'value': 0.085111,\n",
       "      'left': {'feature': 0,\n",
       "       'value': 0.108801,\n",
       "       'left': 6.196516,\n",
       "       'right': {'feature': 0,\n",
       "        'value': 0.10796,\n",
       "        'left': -16.106164,\n",
       "        'right': {'feature': 0,\n",
       "         'value': 0.085873,\n",
       "         'left': -1.293195,\n",
       "         'right': -10.137104}}},\n",
       "      'right': {'feature': 0,\n",
       "       'value': 0.084661,\n",
       "       'left': 37.820659,\n",
       "       'right': {'feature': 0,\n",
       "        'value': 0.080061,\n",
       "        'left': -24.132226,\n",
       "        'right': {'feature': 0,\n",
       "         'value': 0.068373,\n",
       "         'left': 15.824970500000001,\n",
       "         'right': {'feature': 0,\n",
       "          'value': 0.061219,\n",
       "          'left': -15.160836,\n",
       "          'right': {'feature': 0,\n",
       "           'value': 0.044737,\n",
       "           'left': {'feature': 0,\n",
       "            'value': 0.053764,\n",
       "            'left': {'feature': 0,\n",
       "             'value': 0.055862,\n",
       "             'left': 6.695567,\n",
       "             'right': -3.131497},\n",
       "            'right': -13.731698},\n",
       "           'right': 4.091626}}}}}}}}}}}"
      ]
     },
     "execution_count": 11,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "myTree = regTrees.createTree(np.array(myDat2), ops=(1, 0))\n",
    "myDatTest=regTrees.loadDataSet('ex2test.txt')\n",
    "regTrees.prune(myTree, np.array(myDatTest))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'feature': 0,\n",
       " 'value': 0.285477,\n",
       " 'left': array([1.69855694e-03, 1.19647739e+01]),\n",
       " 'right': array([3.46877936, 1.18521743])}"
      ]
     },
     "execution_count": 12,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "myMat2 = np.array(regTrees.loadDataSet('exp2.txt'))\n",
    "regTrees.createTree(myMat2, regTrees.modelLeaf, regTrees.modelErr,(1,10))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXAAAAD4CAYAAAD1jb0+AAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4xLjAsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy+17YcXAAAgAElEQVR4nO3deXDUdZ7/8ee7kw40oA0IHqiIBzoqGTyiM6OO4kZHIoQjKKLizM6x1u7vV7s/d2vLnamtX81v91e/ql/t7u/3c39VW7/fz5r1GMGbcASMVzzHAw0y2ngNHsjgASjQKDSkk7x/fyTd9pWkSbo76c7rUTU1ne/R/fma8Monn9PcHRERKT+B4S6AiIgMjgJcRKRMKcBFRMqUAlxEpEwpwEVEylR1KT9sypQpPmPGjFJ+pIhI2du0adOX7j4183hJA3zGjBm0t7eX8iNFRMqemX2S67iaUEREypQCXESkTCnARUTKlAJcRKRMDRjgZnaXme0ysy0px/7ZzN4zs7fMbLWZTSxuMUVEJFM+NfB7gLkZx54CZrn7d4E/AL8qcLlERGQAAw4jdPcXzGxGxrEnU758FbiusMUSESkfkUiEtrY2otEo4XCY+vp6amtri/65hRgH/jPgob5OmtmtwK0A06dPL8DHiYiMHJFIhLVr19LV1QVANBpl7dq1hPa8yxmBHfDDvynaZw8pwM3s74FOYGVf17j7ncCdAHV1dVp8XEQqSmtrazK8E07p/Ijpz97BXkI8+PphLrt6flFq5IMOcDP7CTAfqHftCiEio1QsFkv7+lx/j8U8zpdMZgVNfPN1By0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nukOXz87yGno5qzGwKPU0qH5W0lIWTz/NuB+oBzOxsegJ8d0lLWTrrgB/3jkb5PhB1988L8s7D3YPbT8/utcAf6OnN/vveY/9Izz9k6PmGPwJ8ALwGnDbcZS7y8z4N7AR+3/u/dcNd5mI+b8a1z1HGo1Dy/P4a8D+Bd4AIsGy4y1zk5z0HeImeESq/B3403GUewrM+AHwOxOmpbf8c+HPgz1O+t//W+98iUsifZU2lFxEpUyO1CUVERAagABcRKVMKcBGRMqUAFxEpUwpwEZEypQAXESlTCnARkTL1/wEjw4+iAJ5sHAAAAABJRU5ErkJggg==\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "regTrees.plotModelTree('exp2.txt')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0.9640852318222141"
      ]
     },
     "execution_count": 20,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 使用regTree的预测结果\n",
    "trainMat=np.array(regTrees.loadDataSet('bikeSpeedVsIq_train.txt'))\n",
    "testMat=np.array(regTrees.loadDataSet('bikeSpeedVsIq_test.txt'))\n",
    "myTree=regTrees.createTree(trainMat, ops=(20,1))\n",
    "yHat = createForecast(myTree, testMat[:,0])\n",
    "np.corrcoef(yHat, testMat[:,1],rowvar=0)[0,1]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0.9760412191380615"
      ]
     },
     "execution_count": 22,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 使用modelTree的预测结果\n",
    "trainMat=np.array(regTrees.loadDataSet('bikeSpeedVsIq_train.txt'))\n",
    "testMat=np.array(regTrees.loadDataSet('bikeSpeedVsIq_test.txt'))\n",
    "myTree=regTrees.createTree(trainMat, regTrees.modelLeaf, regTrees.modelErr, ops=(20,1))\n",
    "yHat = createForecast(myTree, testMat[:,0], modelTreeEval)\n",
    "np.corrcoef(yHat, testMat[:,1],rowvar=0)[0,1]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 25,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0.9434684235674768"
      ]
     },
     "execution_count": 25,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 使用linearSolve的预测结果\n",
    "trainMat=np.array(regTrees.loadDataSet('bikeSpeedVsIq_train.txt'))\n",
    "testMat=np.array(regTrees.loadDataSet('bikeSpeedVsIq_test.txt'))\n",
    "ws, X, y = regTrees.linearSolver(trainMat)\n",
    "yHat = testMat * ws\n",
    "np.corrcoef(yHat, y,rowvar=0)[0,1]"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "关于$R^2$指标参考这个页面：https://windmising.gitbook.io/liu-yu-bo-play-with-machine-learning/5-1/5-6"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Tkinter安装不了，还没解决"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.3"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
